# nodemon --watch fetcher/06practise_search.py --exec 'uv run fetcher/06practise_search.py'

# 下厨房

# url = 'https://www.xiachufang.com/search/?keyword='
# from urllib.parse import quote
# keyword = quote('红烧肉')
# url = url + keyword
# output = './tmp/xiachufang.html'

# # print(url)

# import requests
# resp =  requests.get(url)
# resp.encoding = 'utf-8'
# with open(output, 'w', encoding='utf-8') as f:
#     f.write(resp.text)


# # # ？ 网页时报错了；
# # from urllib.request import urlretrieve
# # urlretrieve(url,'./tmp/xiachufang.html')


# 肯德基 post 获取位置
url = 'https://www.kfc.com.cn/kfccda/ashx/GetStoreList.ashx?op=cname'
# url = 'http://localhost:3000'
# param = {
#     'cname':'武汉',
# }
param = 'cname=%E5%8C%97%E4%BA%AC&pid=&pageIndex=1&pageSize=837'
output = './tmp/kfc.json'


import requests
""" chrome 中 拷贝 (curl,node... 选一种) """
header = {
    "accept": "application/json, text/javascript, */*; q=0.01",
    "accept-language": "en-US,en;q=0.9,zh;q=0.8,zh-CN;q=0.7",
    "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
    "priority": "u=1, i",
    "sec-ch-ua": "\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Google Chrome\";v=\"138\"",
    "sec-ch-ua-mobile": "?0",
    "sec-ch-ua-platform": "\"Windows\"",
    "sec-fetch-dest": "empty",
    "sec-fetch-mode": "cors",
    "sec-fetch-site": "same-origin",
    "x-requested-with": "XMLHttpRequest",
    "cookie": "route-cell=ksa; ASP.NET_SessionId=azahuhvzbn2d4dx5wfpoyfny; VOLCALB=5b62e3bf1f5e98eee334b061a5e2bc10|1754358962|1754356841; VOLCALBCORS=5b62e3bf1f5e98eee334b061a5e2bc10|1754358962|1754356841",
    "Referer": "https://www.kfc.com.cn/kfccda/storelist/index.aspx"
  }
resp =  requests.post(url,data=param,headers=header)
resp.encoding = 'utf-8'
with open(output, 'w', encoding='utf-8') as f:
    f.write(resp.text)